home *** CD-ROM | disk | FTP | other *** search
- /*
- * AutoRemove.c
- * Compilieren mit DICE: dcc AutoRemove.c -o AutoRemove
- */
- #include <intuition/intuition.h>
- struct IntuitionBase *IntuitionBase;
- struct NewWindow NewWindow= {
- 40,50,550,75,0,1,0,WINDOWDRAG|WINDOWDEPTH,0,0,
- (UBYTE *)0,0,0,0,0,0,0,WBENCHSCREEN };
- struct IntuiText IText={1,0,0,25,35,0,
- "Zum Entfernen des Fensters 'AutoRemove' nochmal aufrufen !",
- 0};
- struct Window *Window;
- struct IntuiMessage *IntuiMessage;
- struct MsgPort NewPort,*OldPort,ReplyPort;
- struct Message MsgSend,*MsgReceive;
- void main() {
- if (OldPort=(struct MsgPort *)FindPort("AutoRemove Port")) {
- /* Programm schon im Speicher ? */
- ReplyPort.mp_Node.ln_Pri=0; /* Nachricht an gemeinsamen Port */
- ReplyPort.mp_Node.ln_Name="AutoRemove ReplyPort"; /* schicken */
- ReplyPort.mp_SigTask=(APTR)FindTask(0);
- AddPort(&ReplyPort); /* Reply-Port einrichten */
- MsgSend.mn_Length=sizeof(struct Message); /* Nachricht */
- MsgSend.mn_Node.ln_Type=NT_MESSAGE; /* initialisieren */
- MsgSend.mn_ReplyPort=&ReplyPort;
- PutMsg(OldPort,&MsgSend); /* Message verschicken */
- WaitPort(&ReplyPort); /* auf Antwort warten */
- RemPort(&ReplyPort); /* Reply-Port entf. und Programm verl.*/
- }
- else {
- /* wenn Programm noch nicht im Speicher: Fenster öffnen und */
- /* auf Nachricht warten */
- if (IntuitionBase=(struct IntuitionBase *)
- OpenLibrary("intuition.library",0)) {
- if (Window=(struct Window *)
- OpenWindow(&NewWindow)) { /* Fenster öffnen */
- PrintIText(Window->RPort,&IText,0,0);
- NewPort.mp_Node.ln_Pri=0; /* Port für spätere */
- /* Kommunikation initialisieren */
- NewPort.mp_Node.ln_Name="AutoRemove Port";
- NewPort.mp_SigTask=(APTR)FindTask(0); /* An Port-Liste */
- AddPort(&NewPort); /* anfügen */
- WaitPort(&NewPort); /* Auf Nachricht warten */
- MsgReceive=(APTR)GetMsg(&NewPort); /* Nachricht entfernen */
- ReplyMsg(MsgReceive); /* und beantworten */
- RemPort(&NewPort); /* Port wieder entfernen */
- CloseWindow(Window); /* und Fenster schließen */
- }
- CloseLibrary(IntuitionBase);
- }
- }
- }
-